<?php
if (!defined('APP') or !constant('APP')) die('Direct access not allowed!');

class flash_message {
    const WARN = 1;
    const ERROR = 2;
    const OK = 0;
      
    public static function setMessage($text, $type = flash_message::OK)
    {
        $_SESSION['cms_flash_message'] = $text;
    }
    
    public static function isMessage()
    {
        if (isset($_SESSION['cms_flash_message'])&&!empty($_SESSION['cms_flash_message']))
            return true;
        return false;
    }
    
    public static function getMessage()
    {
        $result = isset($_SESSION['cms_flash_message']) ? $_SESSION['cms_flash_message'] : "";
        unset($_SESSION['cms_flash_message']);
        return addslashes(htmlspecialchars($result, ENT_QUOTES));       
    }
    
}

?>
